import { resolve,join } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import svgLoader from 'vite-svg-loader';
import configArcoStyleImportPlugin from './plugin/arcoStyleImport';
import { writeFileSync } from 'fs'
import qiankun from "vite-plugin-qiankun";

export default defineConfig({
  base: '/saas-service/',
  publicDir: 'public',
  plugins: [
    vue(),
    vueJsx(),
    qiankun("saas-service", { useDevMode: true }),
    svgLoader({ svgoConfig: {} }),
    configArcoStyleImportPlugin(),
  ],
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, '../src'),
      },
      {
        find: 'assets',
        replacement: resolve(__dirname, '../src/assets'),
      },
      {
        find: 'vue',
        replacement: 'vue/dist/vue.esm-bundler.js', // compile template
      }
      
    ],
    extensions: ['.ts', '.js'],
  },
  server: {
    headers: {
      'Access-Control-Allow-Origin': '*',
    }
  },
  define: {
    'process.env': {},
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          hack: `true; @import (reference) "${resolve(
            'src/assets/style/breakpoint.less'
          )}";`,
        },
        javascriptEnabled: true,
      },
    },
  },
    // 添加这个部分来处理 TinyMCE 的资源
  optimizeDeps: {
    include: ['tinymce', '@tinymce/tinymce-vue'],
  },
});
